import type { Component } from "vue";

export default function registerGlobalComponents(app: any) {
  // const componentsDir = import.meta.globEager('@/components/gl-components/*.vue')//vue2中使用，vue3中使用glob
  const componentsDir = import.meta.glob("@/components/gl-components/*.vue", {
    eager: true,
  });

  for (const path in componentsDir) {
    const componentConfig = componentsDir[path] as { default?: Component };
    const componentName = path
      .split("/")
      .pop()
      ?.replace(/\.vue$/, "");
    if (componentName) {
      app.component(componentName, componentConfig.default || componentConfig);
    }
  }
}
